package com.example.xd.fmpeg_test.weight;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.xd.fmpeg_test.R;


public class LoadingDialog extends Dialog {
    private TextView textView;
    private String text;

    public LoadingDialog(@NonNull Context context) {
        super(context, R.style.loading_dialog);
    }

    public LoadingDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected LoadingDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_loading);
        textView = (TextView)this.findViewById(R.id.loading_text);
        textView.setText(text);
        LinearLayout linearLayout = (LinearLayout)this.findViewById(R.id.loading_layout);
        linearLayout.getBackground().setAlpha(210);
    }

    public void setText(String text){
        this.text = text;
        if(textView != null)
            textView.setText(text);
    }
}
